//
//  BCSettingCenterCell.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/12/29.
//  Copyright © 2018 guoshikeji. All rights reserved.
//

#import "BCSettingCenterCell.h"

@implementation BCSettingCenterCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupCenterCellViews];
    }
    return self;
}
- (QMUILabel *)detailsLabel {
    if (!_detailsLabel) {
        _detailsLabel = [QMUILabel new];
        _detailsLabel.textColor = [UIColor qmui_colorWithHexString:@"#AEAEAE"];
        _detailsLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
        [self.contentView addSubview:_detailsLabel];
        [_detailsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.customAccessoryView.mas_left).offset(-5.0);
            make.centerY.mas_equalTo(self.contentView);
        }];
    }
    return _detailsLabel;
}


- (void)setupCenterCellViews {
    self.settingTitleLabel = [QMUILabel new];
    self.settingTitleLabel.textColor = [UIColor qmui_colorWithHexString:@"#333333"];
    self.settingTitleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
    self.settingTitleLabel.adjustsFontSizeToFitWidth = true;
    [self.contentView addSubview:self.settingTitleLabel];
    [self.settingTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.left.mas_equalTo(self.contentView).offset(15.0);
        make.width.mas_lessThanOrEqualTo(self.contentView).multipliedBy(.5).offset(-15.0);
    }];
    //
    UIImage *customAccessoryViewImage = LOAD_IMAGE(@"menu_detail_arrow");
    self.customAccessoryView = [UIImageView new];
    self.customAccessoryView.image = customAccessoryViewImage;
    [self.contentView addSubview:self.customAccessoryView];
    [self.customAccessoryView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.right.mas_equalTo(self.contentView).offset(-15.0);
        make.size.mas_equalTo(customAccessoryViewImage.size);
    }];
    //
    [self addSubview:self.separatorLine];
    [self.separatorLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(10.0);
        make.right.mas_equalTo(self).offset(-10.0);
        make.bottom.mas_equalTo(self);
        make.height.mas_equalTo(1.0);
    }];
}

//
- (void)setCellModel:(SettingCenterCellModel *)cellModel {
    [super setCellModel:cellModel];
    //
    self.settingTitleLabel.text = BCLocalizedKey(cellModel.titleKey);
}

@end
